package com.xuerhua.yxt.controller.sys.signup;

import com.xuerhua.yxt.common.RspResult;
import com.xuerhua.yxt.common.enums.Status;
import com.xuerhua.yxt.controller.BaseController;
import com.xuerhua.yxt.model.FruitsParam;
import com.xuerhua.yxt.model.Grid;
import com.xuerhua.yxt.model.StudentSchoolAge;
import com.xuerhua.yxt.service.IStudentSchoolAgeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@RequestMapping("sys/signUp/newStudentAge")
@Controller
public class SysStudentSchoolAgeController extends BaseController {
    @Autowired
    private IStudentSchoolAgeService studentSchoolAgeService;

    @RequestMapping(value={"","/"})
    public String Index() {
        return "sys/signup/newStudentAge";
    }

    @RequestMapping("pageQuery")
    @ResponseBody
    Object pageQuery(Integer schoolId){
        try {
            List<FruitsParam> list = studentSchoolAgeService.selectList(schoolId);
            Grid grid = new Grid();
            grid.setRows(list);
            grid.setTotal(list.size());
            return grid;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    @RequestMapping("addUpdate")
    @ResponseBody Object addUpdate(StudentSchoolAge studentSchoolAge) {
        try {
            this.studentSchoolAgeService.upadateAge(studentSchoolAge);
            return new RspResult(Status.SUCCESS);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new RspResult(Status.FAIL);
    }
}
